package com.github.wxpay.sdk;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * Created by spoplar on 18-1-26.
 */
public class WXPayConfigImplement extends WXPayConfig {
    private byte[] certData;
    private static WXPayConfigImplement INSTANCE;

    private WXPayConfigImplement() throws Exception{
//        String certPath = "/home/spoplar/certs/cert_dev/apiclient_cert.p12";
//        File file = new File(certPath);
//        InputStream certStream = new FileInputStream(file);
//        this.certData = new byte[(int) file.length()];
//        certStream.read(this.certData);
//        certStream.close();
    }

    public static WXPayConfigImplement getInstance() throws Exception{
        if (INSTANCE == null) {
            synchronized (WXPayConfigImplement.class) {
                if (INSTANCE == null) {
                    INSTANCE = new WXPayConfigImplement();
                }
            }
        }
        return INSTANCE;
    }

    public String getAppID() {
        return "wx57302e3308f9ddaa";
    } //wxab8acb865bb1637e wx57302e3308f9ddaa   wx45510caf94c45640

    public String getMchID() {
        return "1316313901";
    } //11473623 1316313901 1336609301

    public String getKey() {
        return "ZheShiYiGeMiYao12312312312312312";
    } // 2ab9071b06b9f739b950ddb41db2690d  ZheShiYiGeMiYao12312312312312312 32034de515e8bea86153f987549ac22d

    public InputStream getCertStream() {
        ByteArrayInputStream certBis;
        certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }


    public int getHttpConnectTimeoutMs() {
        return 2000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    IWXPayDomain getWXPayDomain() {
        return WXPayDomainImpl.instance();
    }

    public String getPrimaryDomain() {
        return "api.mch.weixin.qq.com";
    }

    public String getAlternateDomain() {
        return "api2.mch.weixin.qq.com";
    }

    @Override
    public int getReportWorkerNum() {
        return 1;
    }

    @Override
    public int getReportBatchSize() {
        return 2;
    }
}
